<?php
include('class/class_connect.php');
include('class/class_page.php');
include('class/class_address.php');
include('class/class_workdays.php');
include('class/class_rating.php');
include('class/class_acts.php');
include('class/abstract/class_mainObjectInfo.php');
include('class/city_rus.php');
include('class/class_checkGetData.php');

foreach($_GET as $key=>$val)
{
	$_GET[$key]=checkGetData::safetyCheck($val);
}
if($_GET['obj']=='nets')
{
	header('location: actscab.php?city='.$_GET['city']);
	exit;
}
if(!($_GET['obj']=='firms' || $_GET['obj']=='malls'))
	checkGetData::error();

$aCheck=new checkGetData(substr($_GET['obj'], 0, 1));
$aCheck->checkCity($_GET['city']);
$aCheck->checkTableId($_GET['city'], $_GET['id']);

$aConnect=new connect(substr($_GET['obj'], 0, 1));
$row=mysql_fetch_array($aConnect->select_all($_GET['city'], "WHERE id='".$_GET['id']."'"));
session_start();

class aFirmPage extends page
{
	var $row=array();
	var $cityRus;
	function __construct($row)
	{		$this->row=$row;
		$this->cityRus=new city_rus_class();
		parent::__construct();
	}
	function title()
	{
		echo 'События '.$this->row['name'].' '.$this->cityRus->city_rus_im($_GET['city']);
	}
	function maincontent()
	{
		if($this->row['division'])
		{
			$division='
			<div class="routeEl">
				<a href="division.php?city='.$_GET['city'].'&division='.$this->row['division'].'">'.$this->row['division'].'</a>
			</div>';
			$subdiv=$this->row['subdiv'];
		}
		else
		{
			$subdiv='Торговые центры';
		}
		echo ('
		<div class="route">
				'.$division.'
			<div class="routeEl">
				<a href="'.$_GET['obj'].'_list.php?city='.$_GET['city'].'&subdiv='.$this->row['subdiv'].'">'.$subdiv.'</a>
			</div>
			<div class="routeEl">
				<a href="'.$_GET['obj'].'.php?city='.$_GET['city'].'&id='.$_GET['id'].'">'.$this->row['name'].'</a>
			</div>
			<div class="routeEl">
				События
			</div>
		</div>
		');
		$aFirmInfo=new aFirmInfo($this->row);
		echo '<center><h1>События</h1></center>';
		$aConnect=new connect(substr($_GET['obj'], 0, 1).'a');
		$act=new acts();
		$act->showActs($_GET['obj'], 100, 300, $_GET['id'], $edit=false);
        //$aPaginator=new newsPaginator();
	}
}


class aFirmInfo extends mainObjectInfo
{
	var $row;
	function __construct($row=array())
	{
		$this->row=$row;
		parent::__construct();
	}
	function showPic()
	{
		echo ('
		<img src="pictures/'.$_GET['obj'].'pics/'.$_GET['city'].'/'.$_GET['id'].'.jpg" title="'.$this->name.'">
		');
		$aFirmRating=new rating(substr($_GET['obj'], 0, 1));
		$aFirmRating->rating($_GET['city'], $this->row['id']);
	}
	function showAddress()
	{
		$address=new address();
		if($_GET['obj']=='firms')
			$address->showSeveralAddresses($this->row['address'], $this->row['link']);
		else
		{
			$addr=explode(',', $this->row['address']);
			$explAddress=$addr[0].'^'.$addr[1].'^'.$this->row['phone'].'^^'.$this->row['workdays'];
			$address->showAddress($explAddress,  $this->row['link']);
		}
	}
	function showshort()
	{
		echo $this->row['short'];
	}
	function showName()
	{
		echo $this->row['name'];
	}
}

$aPage=new aFirmPage($row);

?>